package controller.gui.mainmenu;

import java.awt.event.ActionEvent;

import javax.swing.JButton;

import controller.BackupMapUser;
import controller.Controller;
import controller.NullStaticObjectException;
import controller.PrimaryButtonController;
import controller.StrataNumberListener;
import controller.StrataNumberUser;
import controller.StratumLevelUser;
import controller.states.MapElementToAddStateUser;
import errors.DimensionNotAcceptableException;
import event.numberevent.NumberEvent;
import gui.secondary.BackgroundSecondaryMenu;
import gui.secondary.MapObjectSecondaryMenu;

/**rappresenta il controllore che pilota il pulsante principale per l'inizio del wizard per l'inserimento di
 * uno o pù MapObject
 * 
 * @author koldar
 * @version 1.1
 */
public final class MapObjectWizardController extends PrimaryButtonController implements BackupMapUser,StrataNumberUser,MapElementToAddStateUser{
	
	private MapObjectSecondaryMenu secondarymenu;
	
	public MapObjectWizardController(JButton button,MapObjectSecondaryMenu menu){
		super(button);
		this.secondarymenu=menu;
		this.listenedButton.setEnabled(this.totalStrata.getValue()>0);
	}
	
	@Override
	public void wizardInizializer(ActionEvent arg0)throws NullStaticObjectException, DimensionNotAcceptableException {
		try {
			this.backupmap.setValue(getCurrentmap().clone());
		} catch (CloneNotSupportedException error) {}
		this.mapElementToAddState.setValue(MapElementToAddStateUser.START);
		this.secondarymenu.setVisible(true);
	}
	/**
	 * 
	 */
	@Override
	public void idleUserState(NumberEvent<Integer> arg0){
		this.listenedButton.setEnabled(this.totalStrata.getValue()>0);
	}
	
	

}